package com.xuce.openapi.web.master.service.api;

import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

import java.util.List;
import java.util.Map;

@FeignClient(value = "OPENAPI-CACHE", fallback = CacheServiceFallback.class)
public interface CacheService {
    @RequestMapping(value = "/cache/get/{key}", method = RequestMethod.GET)
    String get(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/setnx/{key}/{value}", method = RequestMethod.POST)
    boolean setnx(@PathVariable("key") String key, @PathVariable("value") String value, @RequestParam("expireSecond") long expireSecond);

    @RequestMapping(value = "/cache/delete/{key}", method = RequestMethod.POST)
    boolean del(@PathVariable("key") String key);

    @RequestMapping(value = "/cache/hmset/{key}", method = RequestMethod.POST)
    boolean hmset(@PathVariable("key") String key, @RequestBody Map<String, Object> map);

    @RequestMapping(value = "/cache/set/{key}/{value}/{expiretime}", method = RequestMethod.POST)
    void set(@PathVariable("key") String key, @PathVariable("value") String value, @PathVariable("expiretime") long expireSecond);

    @RequestMapping(value = "/cache/reverseRangeWithScores", method = RequestMethod.POST)
    List<String> reverseRangeWithScores(@RequestParam("key") String key, @RequestParam("start") int start, @RequestParam("end") int end);

}
